package com.cm.order.controller;

import com.cm.common.core.Result;
import com.cm.order.entity.OrderGoods;
import com.cm.order.mapper.OrderGoodsMapper;
import com.mysql.cj.x.protobuf.MysqlxCrud;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @类 名:OrderGoodsController </br>
 * @描 述:<br>
 * @日 期:2020/10/9 4:06 </br>
 * @作 者:小兰同学</br>
 * @版 本：1.0.0
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/ordergoods")
public class OrderGoodsController {
    @Autowired
    private OrderGoodsMapper orderGoodsMapper;
    @PostMapping("/add")
    public Result addOrderGoods(@RequestBody List<OrderGoods> orderGoodsList){
        for (OrderGoods orderGoods:orderGoodsList){
            if (orderGoodsMapper.insert(orderGoods)<0)
                return Result.fail();
        }
        return Result.success("添加成功");
    }
}
